package com.leoman.plz_p.weidget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.leoman.plz_p.R;

import cn.com.corelib.utils.DisplayUtil;


/**
 * Created by guoh on 2018/7/7.
 */
public class CommitResultDialog extends Dialog{

    private RelativeLayout layout;
    private TextView tvCommitNow;
    private TextView tvReDo;
    private TextView tvNotice;

    public CommitResultDialog(@NonNull Context context) {
        super(context);
    }

    public CommitResultDialog(@NonNull Context context, int themeResId) {
        super(context, R.style.DialogStyle);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_commit_result);
        layout=findViewById(R.id.rl_layout);
        tvCommitNow=findViewById(R.id.tv_commit_now);
        tvReDo=findViewById(R.id.tv_re_answer);
        tvNotice=findViewById(R.id.tv_text);

        Window win = getWindow();
        WindowManager.LayoutParams lp = win.getAttributes();
        lp.gravity = Gravity.CENTER;
        LinearLayout.LayoutParams params= (LinearLayout.LayoutParams) layout.getLayoutParams();
        params.height=(int) (DisplayUtil.getScreenDispaly(getContext())[1]*0.35);
        params.width=(int) (DisplayUtil.getScreenDispaly(getContext())[0]*0.83);
        getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        win.setAttributes(lp);
    }

    public void setCommitClickListener(View.OnClickListener clickListener){
        tvCommitNow.setOnClickListener(clickListener);
    }

    public void setReDoClickListener(View.OnClickListener clickListener){
        tvReDo.setOnClickListener(clickListener);
        findViewById(R.id.iv_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }

    public void setNotDoCount(int count){
        tvNotice.setText("您还剩"+count+"题未做,是否现在交卷?");
    }

}
